<?php 
namespace app\controllers;

use Yii;
use yii\web\Controller;

class TestController extends Controller{
 //         public function actionCreate()
	// {
	// 	 file_put_contents('wei.txt',json_encode($_GET));
 //     	 echo $_GET['echostr'];
	// }
	// public $enableCsrfValidation = false;
    public function actionCreate() {
    	  // file_put_contents('wei.txt','222');
        $xml = file_get_contents('php://input');
        $xml = simplexml_load_string($xml);
        if ($xml->MsgType == 'text') {
            if ($xml->Content == '1') {
                $content = "内容收到";
                $str = "<xml>"
                        . "<ToUserName>".$xml->FromUserName."</ToUserName> "
                        . " <FromUserName>".$xml->ToUserName."</FromUserName>"
                        . "  <CreateTime>".time()."</CreateTime> "
                        . " <MsgType>text</MsgType>  "
                        . "<Content>".$content."</Content>  "
                        . "</xml>";
                echo $str;

           } 
       }
   }
}